<?php

namespace app\admin\controller\Performance;

use app\common\controller\Backend;
use Think\Db;
/**
 * 消息
 *
 * @icon fa fa-circle-o
 */
class Message extends Backend
{
    
    /**
     * Message模型对象
     */
    protected $model = null;
    protected $noNeedRight = ['index'];
    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('Message');
        $this->view->assign("messageTypeList", $this->model->getMessageTypeList());
    }
     /**
     * 查看
     */
    public function index()
    {   
        $id = $this->request->get("id");
        if($id)
        {   $where['message.id'] = $id;
            $message = Db::table("message")
                        ->join("admin","admin.id = message.admin_id")
                        ->where($where)
                        ->field("admin.nickname,message.*")
                        ->find();
            $data['is_read'] = 1;
            Db::table("message")
                        ->where($where)
                        ->update($data);
            $this->view->assign("message",$message);
        }
        return $this->view->fetch();
        //设置过滤方法
        // $this->request->filter(['strip_tags']);
        // if ($this->request->isAjax())
        // {
        //     //如果发送的来源是Selectpage，则转发到Selectpage
        //     if ($this->request->request('pkey_name'))
        //     {
        //         return $this->selectpage();
        //     }
        //     list($where, $sort, $order, $offset, $limit) = $this->buildparams();

        //     $ids = $this->request->get("filter");
        //     dump($ids);
        //     $total = $this->model
        //             ->where($where)
        //             ->order($sort, $order)
        //             ->count();

        //     $list = $this->model
        //             ->where($where)
        //             ->order($sort, $order)
        //             ->limit($offset, $limit)
        //             ->select();

        //     $result = array("total" => $total, "rows" => $list);

        //     return json($result);
        // }
        return $this->view->fetch();
    }

}